﻿<%@ Page Title="" Language="C#" MasterPageFile="~/source/masterpage/base.Master"
    AutoEventWireup="true" CodeBehind="ImportInvoiceManagement.aspx.cs" Inherits="QLK.Web.ImportInvoiceManagement" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 42px;
        }
        .style3
        {
            width: 42px;
            height: 30px;
        }
        .style4
        {
            height: 30px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script language="javascript">

        function SelectAllCheckboxesSpecific(spanChk) {
            var IsChecked = spanChk.checked;
            var Chk = spanChk;
            Parent = document.getElementById('GridImportInvoices');
            var items = Parent.getElementsByTagName('input');
            for (i = 0; i < items.length; i++) {
                if (items[i].id != Chk && items[i].type == "checkbox") {
                    if (items[i].checked != IsChecked) {
                        items[i].click();
                    }
                }
            }
        }
        //or
        function SelectAllCheckboxes(spanChk) {
            var oItem = spanChk.children;
            var theBox = (spanChk.type == "checkbox") ? spanChk : spanChk.children.item[0];
            xState = theBox.checked; // trang thai cua checkbox
            elm = theBox.form.elements;

            for (i = 0; i < elm.length; i++)
                if (elm[i].type == "checkbox" && elm[i].id != theBox.id) {
                if (elm[i].checked != xState) elm[i].click(); // check toan bo thuoc tinh con
            }
        }

        function HighlightRow(chkB) {
            var IsChecked = chkB.checked;
            if (IsChecked) {
                chkB.parentElement.parentElement.style.backgroundColor = '#eee8aa'; //doi mau nen cua row #228b22
                chkB.parentElement.parentElement.style.color = 'white'; //doi font chu cua trong row

            }
            else {
                chkB.parentElement.parentElement.style.backgroundColor = 'white';
                chkB.parentElement.parentElement.style.color = 'black';
            }
        }

        function MouseEvents(objRef, evt) {
            var checkbox = objRef.getElementsByTagName("input")[0];
            if (evt.type == "mouseover") {
                objRef.style.backgroundColor = "orange";
            }
            else {
                if (checkbox.checked)//doi mau row khi checkbox cua dong da duoc check
                {
                    objRef.style.backgroundColor = "tomato";
                }
                else if (evt.type == "mouseout") {
                    if (objRef.rowIndex % 2 != 0)//neu index cua row la so le
                    {
                        //doi mau xen ke giua cac dong
                        objRef.style.backgroundColor = "#FFFBD6";
                    }
                    else////neu index cua row la so chan 
                    {
                        objRef.style.backgroundColor = "white";
                    }
                }
            }
        }
    
</script>

    <table class="style1">
        <tr>
            <td class="style2">
                <asp:Button ID="btnAdd" runat="server" Text="Add" Width="100px" OnClick="btnAdd_Click" />
            </td>
            <td>
                &nbsp;
            </td>
        </tr>
        <tr>
            <td class="style2">
                &nbsp;
            </td>
            <td>
                <asp:GridView ID="GridImportInvoices" runat="server" AutoGenerateColumns="False"
                    CellPadding="4" ForeColor="#333333" GridLines="None" 
                    OnPageIndexChanging="GridImportInvoices_PageIndexChanging" 
                    DataKeyNames="InvoceID">
                    <RowStyle BackColor="#EFF3FB" />
                    <Columns>
                        <asp:TemplateField HeaderText="STT"></asp:TemplateField>
                        <asp:BoundField DataField="InvoceID" HeaderText="InvoiceID" />
                        <asp:BoundField DataField="StorageID" HeaderText="StorageID" />
                        <asp:BoundField DataField="ImportDate" HeaderText="ImportDate" />
                        <asp:BoundField DataField="SupplierID" HeaderText="SupplierID" />
                        <asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID" />
                        <asp:BoundField DataField="TotalValues" HeaderText="TotalValues" />
                        <asp:TemplateField HeaderText="Edit">
                            <ItemTemplate>
                                <asp:ImageButton ID="ImageEdit" runat="server" 
                                    CommandArgument="<%# Eval(QLK.Database.Columns.ImportID) %>" CommandName="Edit" 
                                    ImageUrl="~/images/edit_desc.gif" onclick="ImageEdit_Click" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Check">
                            <HeaderTemplate>
                                <input id="chkAll" runat="server" onclick="javascript:SelectAllCheckboxes(this);"
                                    type="checkbox" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="chkSelect" runat="server" onclick="javascript:HighlightRow(this);" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <EditRowStyle BackColor="#2461BF" />
                    <AlternatingRowStyle BackColor="White" />
                </asp:GridView>
            </td>
        </tr>
        <tr>
            <td class="style3">
                <asp:Button ID="btnAdd2" runat="server" OnClick="btnAdd2_Click" Width="100px" Text="Add" />
            </td>
            <td class="style4">
                &nbsp;
                <asp:Button ID="btnDelete" runat="server" onclick="btnDelete_Click" 
                    Text="Delete" />
            </td>
        </tr>
    </table>
</asp:Content>
